package com.linsir.lin.controller.rbac;

import com.linsir.core.BaseResponse;
import com.linsir.lin.dto.GridDTO;
import com.linsir.lin.dto.RoleDTO;
import com.linsir.lin.pojo.Role;
import com.linsir.lin.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;

/**
 * @ProjectName:linsir-lin
 * @Package:com.linsir.lin.controller
 * @Title: RoleController
 * @Description: TODO
 * @Create:2021/6/10 8:14 by @author:Linsir
 * @Update:2021/6/10 8:14 by @author:Linsir
 * @UpdateRemark: 初始创建
 * @Version 1.0.0
 */

@RestController
@RequestMapping(value = "/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping(value = "/grid",method = {RequestMethod.GET,RequestMethod.POST})
    public GridDTO<RoleDTO> grid(String page,
                                 String limit,
                                 String searchParams) throws IOException, InvocationTargetException, IllegalAccessException {
            return  roleService.grid(page,limit,searchParams);
    }

    @RequestMapping(value = "/add",method = {RequestMethod.POST})
    public BaseResponse<Boolean> doAddAccount(Role role) throws ParseException {
        return  roleService.addOrUpdate(role);
    }
}
